function getObjectURL(file) {
		    var url = null;
		    if (window.createObjectURL != undefined) {
		        url = window.createObjectURL(file)
		    } else if (window.URL != undefined) {
		        url = window.URL.createObjectURL(file)
		    } else if (window.webkitURL != undefined) {
		        url = window.webkitURL.createObjectURL(file)
		    }
		    return url
		};
		var filenum=1;
		$(".add").on("click",function(){
		    $("#file1").trigger("click")
		    $("#file1").on("change",function(){
		    	$("#changePush").attr("check","true")
		        console.log(this.files[0])
		        var srcs = getObjectURL(this.files[0]);
		        $(".pushImg>h2>img").attr("src",srcs) 
		    });
		})
		//客户上传图片
		function ajaxFileUpload() {
		    $.ajaxFileUpload
		    (
		        {
		            url: '/novel/image/upload', //用于文件上传的服务器端请求地址
		            secureuri: false, //是否需要安全协议，一般设置为false
		            fileElementId: 'file1', //文件上传域的ID
		            dataType: 'json', //返回值类型 一般设置为json
		            success: function (data, status)  //服务器成功响应处理函数
		            {
		                if (typeof (data.error) != 'undefined') {
		                    if (data.error != '') {
		                        alert(data.error);
		                    } else {
		                        alert(data.msg);
		                    }
		                }
		            },
		            error: function (data, status, e)//服务器响应失败处理函数
		            {
		                alert(e);
		            }
		        }
		    )
		    return false;
		}
		
		var w_height=$(window).height();
		$(window).on("resize",function(){
		    if($(this).height()<w_height){
		        $("footer").hide()
		    }else{
		        $("footer").show()
		    }
		})
		
		$("#changePush").on("click",function(){
			if($("#changePush").attr("check")=="true"){
		        var fdata = new FormData();
		        //为FormData对象添加数据
//		        for(var i=0;i<$(".changeInfo_content>div").eq(0).find("input").length;i++){
//		            console.log($(".changeInfo_content>div").eq(0).find("input").eq(i).attr("id"))
//		            fdata.append('file[]',$("#"+$(".content>div").eq(0).find("input").eq(0).attr("id"))[0].files[0])
//		        }
		        fdata.append('file[]',$("#file1")[0].files[0])
		        console.log(fdata) 
		        changeNicname()
					$.ajax({
						type:"POST",
						url:"http://120.76.201.26:8088/user/upload",
						beforeSend: function(request) {
							request.setRequestHeader("Authorization","Basic"+localStorage);
						},
						data:{
							file:fdata
						},
						contentType: false,
						success:function(e){
							console.log(e.code)
							console.log(e.data.img_url)
							localStorage.userimg=e.data.img_url
						}
					});
				      function changeNicname(){
				      	console.log($("#nicname").val())
				      	$.ajax({
				      		type:"post",
				      		url:"http://120.76.201.26:8088/user/changeName",
				      		beforeSend: function(request) {
								request.setRequestHeader("Authorization","Basic"+localStorage);
							},
				      		data:{
				      			name:$("#nicname").val()
				      		},
				      		success:function(e){
				      			if(e.code==0){
				      				localStorage.username=$("#nicname").val()
//				      				mui.back()
				      			}
				      		}
				      	});
				      }
		    }else{
		    	console.log(666333)
		    } 
		})




